<script setup>
import { inject }  from 'vue';

const myMsg = inject('myMsg');
const myStr = inject('myStr');
const setMyMsg = inject('setMyMsg');
</script>

<template>
<!-- 结构 -->
<div>
  <div class="sonson">
    <h3>后代组件</h3>
    <p>{{ myMsg }}</p>
    <p>{{ myStr }}</p>
    <button @click="setMyMsg">调用祖先的函数</button>
  </div>
</div>
</template>

<style scoped>
/* 样式 */
.sonson {
  border: 5px solid red;
}
</style>
